package com.weipai.demo.util;

/**
 * @Auther: gusl
 * @Date: 2019/6/4 15:54
 * @Description:
 */
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebAppConfigurer implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/temp-rainy/**").addResourceLocations("file:D:/temp-rainy/");

        String os = System.getProperty("os.name");

        if (os.toLowerCase().startsWith("win")) {  //如果是Windows系统
            registry.addResourceHandler("/temp-rainy/**").addResourceLocations("file:D:/temp-rainy/");
        } else {  //linux 和mac
            registry.addResourceHandler("/temp-rainy/**")
//                        .addResourceLocations("file:/resources/smallapple/");//媒体资源
                    .addResourceLocations("file:/usr/local/temp-rainy/");//媒体资源
        }

    }
    }


